/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package service;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author andrew
 */
@Entity
@Table(name = "Universe")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Universe.findAll", query = "SELECT u FROM Universe u"),
    @NamedQuery(name = "Universe.findByIdUniverse", query = "SELECT u FROM Universe u WHERE u.idUniverse = :idUniverse"),
    @NamedQuery(name = "Universe.findByName", query = "SELECT u FROM Universe u WHERE u.name = :name"),
    @NamedQuery(name = "Universe.findByDescription", query = "SELECT u FROM Universe u WHERE u.description = :description"),
    @NamedQuery(name = "Universe.findByIsValidated", query = "SELECT u FROM Universe u WHERE u.isValidated = :isValidated")})
public class Universe implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "isReady")
    private int isReady;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idUniverse")
    private Integer idUniverse;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 70)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "isValidated")
    private boolean isValidated;
    @JoinTable(name = "Universe_has_MumuUser", joinColumns = {
        @JoinColumn(name = "Universe_idUniverse", referencedColumnName = "idUniverse")}, inverseJoinColumns = {
        @JoinColumn(name = "MumuUser_idUser", referencedColumnName = "idUser")})
    @ManyToMany
    private Collection<MumuUser> mumuUserCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "universeidUniverse")
    private Collection<Planet> planetCollection;

    public Universe() {
    }

    public Universe(Integer idUniverse) {
        this.idUniverse = idUniverse;
    }

    public Universe(Integer idUniverse, String name, String description, boolean isValidated) {
        this.idUniverse = idUniverse;
        this.name = name;
        this.description = description;
        this.isValidated = isValidated;
    }

    public Integer getIdUniverse() {
        return idUniverse;
    }

    public void setIdUniverse(Integer idUniverse) {
        this.idUniverse = idUniverse;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public boolean getIsValidated() {
        return isValidated;
    }

    public void setIsValidated(boolean isValidated) {
        this.isValidated = isValidated;
    }

    @XmlTransient
    public Collection<MumuUser> getMumuUserCollection() {
        return mumuUserCollection;
    }

    public void setMumuUserCollection(Collection<MumuUser> mumuUserCollection) {
        this.mumuUserCollection = mumuUserCollection;
    }

    @XmlTransient
    public Collection<Planet> getPlanetCollection() {
        return planetCollection;
    }

    public void setPlanetCollection(Collection<Planet> planetCollection) {
        this.planetCollection = planetCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idUniverse != null ? idUniverse.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Universe)) {
            return false;
        }
        Universe other = (Universe) object;
        if ((this.idUniverse == null && other.idUniverse != null) || (this.idUniverse != null && !this.idUniverse.equals(other.idUniverse))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "service.Universe[ idUniverse=" + idUniverse + " ]";
    }

    public int getIsReady() {
        return isReady;
    }

    public void setIsReady(int isReady) {
        this.isReady = isReady;
    }
    
}
